﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="备品备件入库.aspx.cs" Inherits="syc.Jidong.备品备件入库" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>备品备件入库</title>
<link rel="stylesheet" href="/js/autocomplete/jquery.autocomplete.css" type="text/css" />
<script src="/js/autocomplete/lib/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/autocomplete/lib/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="/js/autocomplete/jquery.autocomplete.js"></script>
</head>
<body onload="load()">
<script type="text/javascript" language="javascript" src="/common.js"></script>
    <form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

     <div id="Div1" class="wintop" style="width:600px">分厂备品备件入库<br />
     </div>        

  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>      
     <asp:Panel ID="Panel3" runat="server" CssClass="panel" style="width:595px">
        <table>
        <tr>
        <td><input id="New" type="button" value="新  增" class="button" />       
        </td>
  
        <td>年份：</td>
        <td>
            <asp:DropDownList ID="Year" runat="server" AutoPostBack="True">
                <asp:ListItem>2009</asp:ListItem>
                <asp:ListItem>2010</asp:ListItem>
                <asp:ListItem>2011</asp:ListItem>
                <asp:ListItem>2012</asp:ListItem>
                <asp:ListItem>2013</asp:ListItem>
                <asp:ListItem>2014</asp:ListItem>
                <asp:ListItem>2015</asp:ListItem>
            </asp:DropDownList>
        </td>
        <td>月份：</td>
        <td>
            <asp:DropDownList ID="Month" runat="server" AutoPostBack="True">
                <asp:ListItem Value="1">一月</asp:ListItem>
                <asp:ListItem Value="2">二月</asp:ListItem>
                <asp:ListItem Value="3">三月</asp:ListItem>
                <asp:ListItem Value="4">四月</asp:ListItem>
                <asp:ListItem Value="5">五月</asp:ListItem>
                <asp:ListItem Value="6">六月</asp:ListItem>
                <asp:ListItem Value="7">七月</asp:ListItem>
                <asp:ListItem Value="8">八月</asp:ListItem>
                <asp:ListItem Value="9">九月</asp:ListItem>
                <asp:ListItem Value="10">十月</asp:ListItem>
                <asp:ListItem Value="11">十一月</asp:ListItem>
                <asp:ListItem Value="12">十二月</asp:ListItem>
            </asp:DropDownList>        
        </td>
        </tr>
        </table>
     </asp:Panel>
     <asp:Panel ID="Panel2" runat="server" CssClass="panel">
        <table style="width: 100%">
            <tr>
     <td width="400">
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
            UpdateCommand="UPDATE [备品备件收支表] SET [品名] = @品名, [类别ID] = @类别ID, [生产线] = @生产线, [数量] = @数量, [单价] = @单价, [收支] = @收支, [年份] = @年份, [月份] = @月份, [日期] = @日期 WHERE [ID] = @ID" 
            
                        InsertCommand="INSERT INTO [备品备件收支表] ([品名], [类别ID], [生产线], [数量], [单价], [收支], [年份], [月份], [日期]) VALUES (@品名, @类别ID, @生产线, @数量, @单价, 0, @年份, @月份, @日期)" 
                        DeleteCommand="DELETE FROM [备品备件收支表] WHERE [ID] = @ID" SelectCommand="SELECT [ID], [品名], [类别ID], [生产线], [数量], [单价], [收支], [年份], [月份], [日期] FROM [备品备件收支表] WHERE (([生产线] = @生产线) AND ([年份] = @年份) AND ([数量] = @数量))"
            >
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="1" Name="生产线" 
                    QueryStringField="fenchang" Type="Int32" />
                <asp:ControlParameter ControlID="Year" DefaultValue="2010" Name="年份" 
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:ControlParameter ControlID="Month" DefaultValue="1" Name="月份" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="品名" Type="String" />
                <asp:Parameter Name="类别ID" Type="Int32" />
                <asp:Parameter Name="生产线" Type="Int32" />
                <asp:Parameter Name="数量" Type="Decimal" />
                <asp:Parameter Name="单价" Type="Decimal" />
                <asp:Parameter Name="收支" Type="Boolean" />
                <asp:Parameter Name="年份" Type="Int32" />
                <asp:Parameter Name="月份" Type="Int32" />
                <asp:Parameter Name="日期" Type="DateTime" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:QueryStringParameter DefaultValue="1" Name="生产线" 
                    QueryStringField="fenchang" Type="Int32" />
                <asp:ControlParameter ControlID="Year" DefaultValue="2010" Name="年份" 
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:ControlParameter ControlID="Month" DefaultValue="1" Name="月份" 
                    PropertyName="SelectedValue" Type="Int32" />
                <asp:Parameter Name="品名" Type="String" />
                <asp:Parameter Name="类别ID" Type="Int32" DefaultValue="1"/>
                <asp:Parameter Name="数量" Type="Decimal" />
                <asp:Parameter Name="单价" Type="Decimal" />
                <asp:Parameter Name="日期" Type="DateTime"/>
            </InsertParameters>
                    </asp:SqlDataSource>

                    <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" 
             DataSourceID="SqlDataSource1" DefaultMode="Insert">
                        <EditItemTemplate>
                            ID:
                            <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
                            <br />
                            品名:
                            <asp:TextBox ID="品名TextBox" CssClass="txtSearch" runat="server" Text='<%# Bind("品名") %>' />
                            <br />
                            类别ID:
                            <asp:TextBox ID="类别IDTextBox" runat="server" Text='<%# Bind("类别ID") %>' />
                            <br />
                            生产线:
                            <asp:TextBox ID="生产线TextBox" runat="server" Text='<%# Bind("生产线") %>' />
                            <br />
                            数量:
                            <asp:TextBox ID="数量TextBox" runat="server" Text='<%# Bind("数量") %>' />
                            <br />
                            单价:
                            <asp:TextBox ID="单价TextBox" runat="server" Text='<%# Bind("单价") %>' />
                            <br />
                            收支:
                            <asp:CheckBox ID="收支CheckBox" runat="server" Checked='<%# Bind("收支") %>' />
                            <br />
                            年份:
                            <asp:TextBox ID="年份TextBox" runat="server" Text='<%# Bind("年份") %>' />
                            <br />
                            月份:
                            <asp:TextBox ID="月份TextBox" runat="server" Text='<%# Bind("月份") %>' />
                            <br />
                            日期:
                            <asp:TextBox ID="日期TextBox" runat="server" Text='<%# Bind("日期") %>' />
                            <br />
                            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                                CommandName="Update" Text="更新" />
                            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                                CausesValidation="False" CommandName="Cancel" Text="取消" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                        <div style="margin:10px;">
                        <table>
                            <tr>
                            <td>品名:</td>
                            <td><asp:TextBox ID="品名TextBox" CssClass="txtSearch" runat="server" Text='<%# Bind("品名") %>'/></td>
                            </tr>
                            <tr>
                            <td>数量:</td>
                            <td><asp:TextBox ID="数量TextBox" CssClass="kcSearch" runat="server" Text='<%# Bind("数量") %>' /></td>
                            </tr>                        
                            <tr>
                            <td>                           
                            单价:
                            </td>
                            <td>
                            <asp:TextBox ID="单价TextBox" runat="server" Text='<%# Bind("单价") %>' />                            
                            </td>
                            </tr>
                            <tr>
                            <td>日期:</td>
                            <td><asp:TextBox ID="日期TextBox" runat="server" Text='<%# Bind("日期") %>' /></td>
                            </tr>                            
                         </table>  
                           </div>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            ID:
                            <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
                            <br />
                            品名:
                            <asp:Label ID="品名Label" runat="server" Text='<%# Bind("品名") %>' />
                            <br />
                            类别ID:
                            <asp:Label ID="类别IDLabel" runat="server" Text='<%# Bind("类别ID") %>' />
                            <br />
                            生产线:
                            <asp:Label ID="生产线Label" runat="server" Text='<%# Bind("生产线") %>' />
                            <br />
                            数量:
                            <asp:Label ID="数量Label" runat="server" Text='<%# Bind("数量") %>' />
                            <br />
                            单价:
                            <asp:Label ID="单价Label" runat="server" Text='<%# Bind("单价") %>' />
                            <br />
                            收支:
                            <asp:CheckBox ID="收支CheckBox" runat="server" Checked='<%# Bind("收支") %>' 
                                Enabled="false" />
                            <br />
                            年份:
                            <asp:Label ID="年份Label" runat="server" Text='<%# Bind("年份") %>' />
                            <br />
                            月份:
                            <asp:Label ID="月份Label" runat="server" Text='<%# Bind("月份") %>' />
                            <br />
                            日期:
                            <asp:Label ID="日期Label" runat="server" Text='<%# Bind("日期") %>' />
                            <br />
                            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                                CommandName="Edit" Text="编辑" />
                            &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                                CommandName="Delete" Text="删除" />
                            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                                CommandName="New" Text="新建" />
                        </ItemTemplate>
         </asp:FormView>

                </td>
                <td valign="top"><br />
                    <asp:Button ID="Button_Save" runat="server" Text="保  存" CssClass="button" 
                        onclick="Button_Save_Click" />
                    <input id="Cancel" type="button" value="取 消" class="button" />    
                    <div class="prompt">
                    标有 <span class="required">*</span> 表示必须填写
                    </div>
                </td>

            </tr>

        </table>

    </asp:Panel>
     </ContentTemplate>
   </asp:UpdatePanel>      
   
   <asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <ContentTemplate>    
    <div class="gridframe">
        <div class="gridview">
        
            <table border="1" width="60%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
	            <tr>
		            <td class="grid-title">分厂备品备件出库记录

                    </td>
		        </tr>
		        <tr>
		            <td class="grid-back">

                                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"                                           
                            
                                    SelectCommand="SELECT [品名], [单价], [数量], [日期] FROM [备品备件收支表] WHERE (([生产线] = @生产线) AND ([年份] = @年份) AND ([月份] = @月份) AND ([收支] = 0))">
                                    <SelectParameters>
                                        <asp:QueryStringParameter DefaultValue="1" Name="生产线" 
                                    QueryStringField="fenchang" Type="Int32" />
                                        <asp:ControlParameter ControlID="Year" DefaultValue="2010" Name="年份" 
                                            PropertyName="SelectedValue" Type="Int32" />
                                        <asp:ControlParameter ControlID="Month" DefaultValue="1" Name="月份" 
                                            PropertyName="SelectedValue" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                                    AllowSorting="True" AutoGenerateColumns="False" CssClass="grid" 
                                    DataSourceID="SqlDataSource2" GridLines="None" 
                                    ondatabound="GridView1_DataBound" 
                                    onpageindexchanged="GridView1_PageIndexChanged" 
                                    UseAccessibleHeader="False">
                                    <PagerSettings Visible="False" />
                                    <RowStyle CssClass="grid-row-normal" />
                                    <Columns>
                                        <asp:BoundField DataField="品名" HeaderStyle-CssClass="grid-header" 
                                            HeaderText="品名" ItemStyle-CssClass="grid" ItemStyle-Width="160" 
                                            ItemStyle-HorizontalAlign="Center"
                                            SortExpression="品名">
                                            <HeaderStyle CssClass="grid-header" />
                                            <ItemStyle CssClass="grid" Width="160px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="单价" HeaderStyle-CssClass="grid-header" 
                                            HeaderText="单价" ItemStyle-CssClass="grid" ItemStyle-Width="160" 
                                            ItemStyle-HorizontalAlign="Center"
                                            SortExpression="单价">
                                            <HeaderStyle CssClass="grid-header" />
                                            <ItemStyle CssClass="grid" Width="160px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="数量" HeaderStyle-CssClass="grid-header" 
                                            HeaderText="数量" ItemStyle-CssClass="grid" ItemStyle-HorizontalAlign="Center" 
                                            ItemStyle-Width="80" SortExpression="数量">
                                            <HeaderStyle CssClass="grid-header" />
                                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="日期" HeaderStyle-CssClass="grid-header" 
                                            HeaderText="日期" ItemStyle-CssClass="grid" ItemStyle-HorizontalAlign="Center" 
                                            ItemStyle-Width="80" SortExpression="日期" DataFormatString="{0:d}">
                                            <HeaderStyle CssClass="grid-header" />
                                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                                        </asp:BoundField>                                        
                                    </Columns>
                                </asp:GridView>
                                <table width="100%">
                                    <tr>
                                        <td class="pagebar">
                                            <asp:Button ID="Button_Pager_First" runat="server" CommandName="--" 
                                                CssClass="pageturn-first-b" onclick="Pager_Click" Text="" ToolTip="首页" />
                                            <asp:Button ID="Button_Pager_Prev" runat="server" CommandName="-" 
                                                CssClass="pageturn-prev-b" onclick="Pager_Click" Text="" ToolTip="上一页" />
                                            <input class="page-split" type="button" />第<asp:TextBox ID="TextBox_Pager" 
                                                runat="server" CssClass="pageturn" ontextchanged="Pager_Click"></asp:TextBox>
                                            页<input class="page-split" type="button" /><asp:Label ID="Label_Pages" 
                                                runat="server"></asp:Label>
                                            <input class="page-split" type="button" />
                                            <asp:Button ID="Button_Pager_Next" runat="server" CommandName="+" 
                                                CssClass="pageturn-next-b" onclick="Pager_Click" Text="" ToolTip="下一页" />
                                            <asp:Button ID="Button_Pager_Last" runat="server" CommandName="++" 
                                                CssClass="pageturn-last-b" onclick="Pager_Click" Text="" ToolTip="末页" />
                                        </td>
                                        <td align="right">
                                            <asp:Label ID="Label_Total" runat="server" CssClass="grid_totalrows"></asp:Label>
                                        </td>
                                    </tr>
                                </table>

		            </td>
	            </tr>
            </table>
         

        </div>
    </div>
    </ContentTemplate>
   </asp:UpdatePanel>
   </form>
<script type="text/javascript">
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }

    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
        }
    }
    var tds = document.getElementsByTagName("td");
    for (i = 0; i < tds.length; i++) {
        if (tds[i].className == "detailheader") {
            tds[i].innerHTML = tds[i].innerHTML.replace("*", "<span class=required>*</span>");
        }
    }
</script>    
<script type="text/javascript">
    function load() {
        //alert("Hello from Load");
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        EndRequestHandler();
    }

    function EndRequestHandler() {
        $("#Panel2").hide();
        $("#New").click(function() {
            //alert("fasd");
            $("#Panel2").show();
        }
        );
        $("#Cancel").click(function() {
            //alert("fasd");
            $("#Panel2").hide();
        }
        );
        //alert("Hello From EndRequestHandler()");
        $(".txtSearch").autocomplete("m.aspx", {
            minChars: 0,
            max: 5,
            autoFill: true,
            mustMatch: true,
            matchContains: true,
            scrollHeight: 220,
            formatItem: function(data, i, total) {
                return "<I>" + data[0] + "</I>";
            },
            formatMatch: function(data, i, total) {
                return data[0];
            },
            formatResult: function(data) {
                return data[0];
            }
        });        
    }
  </script>
</body>
</html>
